package com.google.code.fulltank.strategy;

import com.google.code.fulltank.FuelTank;
import com.google.code.fulltank.price.FuelPriceHistory;
import com.google.code.fulltank.usage.FuelUsageHistory;
import org.joda.time.LocalDate;

/**
 * Implements a Naive "fuel when needed" strategy: fill up the tank when it is
 * too low to last the day.
 *
 * @author DL
 */
public class NaiveStrategy extends FuelingStrategy {
    public NaiveStrategy(
        FuelTank tank, FuelPriceHistory prices, FuelUsageHistory usage) {

        super(tank, prices, usage);
    }


    @Override
    public double onDate(LocalDate date) {
        if (usage.getFuelUsage(date) <= tank.getFuelAmount()) {
            return 0;
        }

        return Double.POSITIVE_INFINITY;
    }
}
